package org.catspaw.cherubim.text.stroke;

import java.io.File;
import java.net.URL;

public class ChineseStrokeDictionary extends TextBasedStrokeDictionary {

	private static final String	DEFAULT_DICTIONARY	= "ChineseStrokeDictionary.csv";

	public ChineseStrokeDictionary(String fileName) {
		super(fileName);
	}

	public ChineseStrokeDictionary(File file) {
		super(file);
	}

	public ChineseStrokeDictionary(URL url) {
		super(url);
	}

	public ChineseStrokeDictionary() {
		super(initUrl());
	}

	private static URL initUrl() {
		URL url = ChineseStrokeDictionary.class.getResource(DEFAULT_DICTIONARY);
		return url;
	}

	@Override
	protected DefaultStrokeDictionaryEntry parseLine(String line) {
		String[] ss = line.split(",");
		char c = ss[0].trim().charAt(0);
		int codePoint = Integer.parseInt(ss[1].trim());
		int stroke = Integer.parseInt(ss[2].trim());
		DefaultStrokeDictionaryEntry entry = new DefaultStrokeDictionaryEntry(
				c, codePoint, stroke);
		return entry;
	}
}
